'use strict';

import Vue from 'vue'
import util from '@/util/Util'
import qs from 'qs'

const _vue = new Vue()

const _live = {
	// 发送用户私聊消息
	'sendMessage': function(param) {
		return _vue.$axios.post(util.getServerUrl('/chat/sendMessage'), {
				'fromUser': param.fromUser,
				'toUser': param.toUser,
				'message': param.message,
			})
			.then(function(response) {
				if(param.success) {
					param.success(response)
				}
				return response
			})
			.catch(function(error) {
				console.log(error)
			})
	},
	// 获取用户私聊消息
	'getMessage': function(param) {
		return _vue.$axios.post(util.getServerUrl('/chat/getMessage'), {
				'fromUser': param.fromUser,
				'toUser': param.toUser,
			})
			.then(function(response) {
				if(param.success) {
					param.success(response)
				}
				return response
			})
			.catch(function(error) {
				console.log(error)
			})
	},
}

export default _live